const express = require('express');
const router = express.Router();

const deanTask = require('../../controller/dean')
const error = require('../../middleware/err-handle')
const taskValidata = require('../../validator/task')
const auth = require('../../middleware/webAuth')

const journal = require('../../controller/journal')


// 任务列表
router.get('/getTasks', auth(), deanTask.getTasks)
    // 分解任务
router.post('/createTask', auth(), taskValidata.createTask, deanTask.createTask, journal.journalCreate)
    // 获取任务
router.get('/getTask/:taskId', auth(), taskValidata.getTask, deanTask.getTask)
    // 更新任务
router.put('/updataTask/:taskId', auth(), taskValidata.deanUpdataTask, deanTask.updataTask, journal.journalCreate)
    // 删除任务
router.delete('/deleteTask/:taskId', auth(), taskValidata.deleteTask, deanTask.deleteTask, journal.journalCreate)
// 删除单个文件
router.delete('/deleteFile/:taskId', auth(), deanTask.deleteFile)
// 删除多个文件
router.delete('/deleteAllFile/:taskId', auth(), deanTask.deleteAllFile)
// 下载文件
router.post('/download/:taskId', auth(), deanTask.download)
// 获取职位
router.post('/position', auth(), deanTask.position)
// 全局统计
router.get('/statistical', auth(), deanTask.statistical)
//错误处理中间键
router.use(error())

module.exports = router